Plots of the two triangle linkage that this file generates:

  1. no boundary, no fixing of trivial dofs
  2. boundary, nofixing of trivial dofs
  3. no boundary, fixed face
  4. no boundary, fixed center of mass
  5. no boundary, fixed center of mass and rotation
  6. boundary, fixed center of mass and rotation

In [116]:
%matplotlib inline

In [117]:
import datetime
dts = str(datetime.datetime.now())
date_time_str = dts[:10] + "-" + dts[11:13] + "-" + dts[14:16]
print date_time_str


2015-03-31-20-36

In [118]:
import numpy as np

import matplotlib.pyplot as plt

import bga_4_0 as bga
import manifold_reflected_brownian_motion as mrbm

import os

bga = reload(bga)
mrbm = reload(mrbm)

In [119]:
save_images = False

from matplotlib import rc
rc('font', **{'family':'serif','serif':['Palatino']})
rc('text', usetex=True)

fig_width = 10
fig_height = 6
my_figsize = (fig_width, fig_height)
fig_dpi = 200
my_dpi = fig_dpi

In [120]:
manifold_name = 'building_game'
poly_name = 'octahedron'
int_num = 2

unary_boundary_name = 'self_intersection'
binary_boundary_name = 'dihedrals'

stat_name = 'test_1'

In [121]:
manifold_kwargs_simple = {'poly_name': poly_name, 
                          'int_num': int_num}
manifold_kwargs_fface = {'poly_name': poly_name, 
                          'int_num': int_num, 
                          'fixed_face': 0}
manifold_kwargs_com = {'poly_name': poly_name, 
                          'int_num': int_num, 
                          'fixed_com': True}
manifold_kwargs_comrot = {'poly_name': poly_name, 
                          'int_num': int_num, 
                          'fixed_com': True,
                          'fixed_rotation': True}

In [122]:
unary_boundary_kwargs = {'poly_name': poly_name, 'int_num': int_num}
binary_boundary_kwargs = {'poly_name': poly_name, 'int_num': int_num}

In [123]:
stat_kwargs = {}

In [124]:
err_tol = 10**-11
h = 0.05
N = 2*10**7

hist_min = 0.0
hist_max = 2.0*np.pi
hist_bins = 1000

In [125]:
kwargs_1  = {'manifold_name': manifold_name,  
             'stat_name': stat_name,
             'manifold_kwargs': manifold_kwargs_simple,
             'stat_kwargs': stat_kwargs,
             'record_hist': True, 
             'hist_min': hist_min, 
             'hist_max': hist_max, 
             'hist_bins': hist_bins,
             'err_tol': err_tol}

In [126]:
kwargs_2  = {'manifold_name': manifold_name,  
             'unary_boundary_name': unary_boundary_name,
             'binary_boundary_name': binary_boundary_name,
             'stat_name': stat_name,
             'manifold_kwargs': manifold_kwargs_simple,
             'unary_boundary_kwargs': unary_boundary_kwargs,
             'binary_boundary_kwargs': binary_boundary_kwargs,
             'stat_kwargs': stat_kwargs,
             'record_hist': True, 
             'hist_min': hist_min, 
             'hist_max': hist_max, 
             'hist_bins': hist_bins,
             'err_tol': err_tol}

In [127]:
kwargs_3  = {'manifold_name': manifold_name,  
             'stat_name': stat_name,
             'manifold_kwargs': manifold_kwargs_fface,
             'stat_kwargs': stat_kwargs,
             'record_hist': True, 
             'hist_min': hist_min, 
             'hist_max': hist_max, 
             'hist_bins': hist_bins,
             'err_tol': err_tol}

In [128]:
kwargs_4  = {'manifold_name': manifold_name,  
             'stat_name': stat_name,
             'manifold_kwargs': manifold_kwargs_com,
             'stat_kwargs': stat_kwargs,
             'record_hist': True, 
             'hist_min': hist_min, 
             'hist_max': hist_max, 
             'hist_bins': hist_bins,
             'err_tol': err_tol}

In [129]:
kwargs_5  = {'manifold_name': manifold_name,  
             'stat_name': stat_name,
             'manifold_kwargs': manifold_kwargs_comrot,
             'stat_kwargs': stat_kwargs,
             'record_hist': True, 
             'hist_min': hist_min, 
             'hist_max': hist_max, 
             'hist_bins': hist_bins,
             'err_tol': err_tol}

In [130]:
kwargs_6  = {'manifold_name': manifold_name,  
             'unary_boundary_name': unary_boundary_name,
             'binary_boundary_name': binary_boundary_name,
             'stat_name': stat_name,
             'manifold_kwargs': manifold_kwargs_comrot,
             'unary_boundary_kwargs': unary_boundary_kwargs,
             'binary_boundary_kwargs': binary_boundary_kwargs,
             'stat_kwargs': stat_kwargs,
             'record_hist': True, 
             'hist_min': hist_min, 
             'hist_max': hist_max, 
             'hist_bins': hist_bins,
             'err_tol': err_tol}

In [131]:
x0, links, lengths, faces = bga.load_bg_int(poly_name, int_num)

In [132]:
filename = lambda n: "T2_" + str(n) + ".pkl"

In [133]:
a = 0.5/np.pi
b = -a*0.1
c = -a*0.1
a2 = a
b2 = 0.028
x_range = np.linspace(0.0, 2.0*np.pi)
ys = a + b*np.cos(x_range) + c*np.cos(2*x_range)
ys2 = a2 + b2*np.cos(x_range)

In [134]:
if os.path.isfile(filename(1)):
    print "Reading z_1 from file..."
    z_1 = mrbm.MRBM.load(filename(1))
else:
    print "Generating z_1 samples..."
    z_1 = mrbm.MRBM(x0, h, **kwargs_1)
    s_1 = z_1.sample(N=N, record_trace=False, record_stats=False)
    z_1.dump(filename(1))


Generating z_1 samples...

In [135]:
fig = plt.figure(dpi=my_dpi, figsize=my_figsize)
xx1 = plt.hist(z_1.hist.midpoints, weights=z_1.hist.hist[0,:], normed=True, bins=40)
yy1 = plt.plot(x_range, ys, 'r', lw=2) 
plt.title("Two Triangle Linkage with No Boundaries")
plt.xlabel("Dihedral Angle")
plt.ylabel("Frequency")
plt.xlim(0.0, np.pi*2)
plt.savefig('T2_1.eps', dpi=my_dpi)



In [136]:
if os.path.isfile(filename(2)):
    print "Reading z_2 from file..."
    z_2 = mrbm.MRBM.load(filename(2))
else:
    print "Generating z_2 samples..."
    z_2 = mrbm.MRBM(x0, h, **kwargs_2)
    s_2 = z_2.sample(N=N, record_trace=False, record_stats=False)
    z_2.dump(filename(2))


Reading z_2 from file...

In [137]:
fig = plt.figure(dpi=my_dpi, figsize=my_figsize)
xx1 = plt.hist(z_2.hist.midpoints, weights=z_2.hist.hist[0,:], normed=True, bins=50)
yy1 = plt.plot(x_range, ys, 'r', lw=2) 
plt.title("Two Triangle Linkage with Boundaries")
plt.xlabel("Dihedral Angle")
plt.ylabel("Frequency")
plt.xlim(0.0, np.pi*2)
plt.savefig('T2_2.eps', dpi=my_dpi)



In [138]:
"""if os.path.isfile(filename(3)):
    print "Reading z_3 from file..."
    z_3 = mrbm.MRBM.load(filename(3))
else:
    print "Generating z_3 samples..."
    z_3 = mrbm.MRBM(x0, h, **kwargs_3)
    s_3 = z_3.sample(N=N, record_trace=False, record_stats=False)
    z_3.dump(filename(3))"""


Out[138]:
'if os.path.isfile(filename(3)):\n    print "Reading z_3 from file..."\n    z_3 = mrbm.MRBM.load(filename(3))\nelse:\n    print "Generating z_3 samples..."\n    z_3 = mrbm.MRBM(x0, h, **kwargs_3)\n    s_3 = z_3.sample(N=N, record_trace=False, record_stats=False)\n    z_3.dump(filename(3))'

In [139]:
fig = plt.figure(dpi=my_dpi, figsize=my_figsize)
xx1 = plt.hist(z_2.hist.midpoints, weights=z_2.hist.hist[0,:], normed=True, bins=50)
yy1 = plt.plot(x_range, ys, 'r', lw=2) 
plt.title("Two Triangle Linkage withFixed Face NEEDS UPDATE")
plt.xlabel("Dihedral Angle")
plt.ylabel("Frequency")
plt.xlim(0.0, np.pi*2)
plt.savefig('T2_3.eps', dpi=my_dpi)



In [140]:
if os.path.isfile(filename(4)):
    print "Reading z_4 from file..."
    z_4 = mrbm.MRBM.load(filename(4))
else:
    print "Generating z_4 samples..."
    z_4 = mrbm.MRBM(x0, h, **kwargs_4)
    s_4 = z_4.sample(N=N, record_trace=False, record_stats=False)
    z_4.dump(filename(4))


Reading z_4 from file...

In [141]:
fig = plt.figure(dpi=my_dpi, figsize=my_figsize)
xx1 = plt.hist(z_4.hist.midpoints, weights=z_4.hist.hist[0,:], normed=True, bins=50)
yy1 = plt.plot(x_range, ys, 'r', lw=2) 
plt.title("Two Triangle Linkage with Fixed Center of Mass and No Boundaries")
plt.xlabel("Dihedral Angle")
plt.ylabel("Frequency")
plt.xlim(0.0, np.pi*2)
plt.savefig('T2_4.eps', dpi=my_dpi)



In [142]:
if os.path.isfile(filename(5)):
    print "Reading z_5 from file..."
    z_5 = mrbm.MRBM.load(filename(5))
else:
    print "Generating z_5 samples..."
    z_5 = mrbm.MRBM(x0, h, **kwargs_5)
    s_5 = z_5.sample(N=N, record_trace=False, record_stats=False)
    z_5.dump(filename(5))


Reading z_5 from file...

In [143]:
fig = plt.figure(dpi=my_dpi, figsize=my_figsize)
xx1 = plt.hist(z_5.hist.midpoints, weights=z_5.hist.hist[0,:], normed=True, bins=50)
#yy1 = plt.plot(x_range, ys, 'r', lw=2) 
yy1 = plt.plot(x_range, ys2, 'g', lw=2) 
plt.title("Two Triangle Linkage with Fixed Center of Mass and Rotation with No Boundaries")
plt.xlabel("Dihedral Angle")
plt.ylabel("Frequency")
plt.xlim(0.0, np.pi*2)
plt.savefig('T2_5.eps', dpi=my_dpi)



In [144]:
if os.path.isfile(filename(6)):
    print "Reading z_6 from file..."
    z_6 = mrbm.MRBM.load(filename(6))
else:
    print "Generating z_6 samples..."
    z_6 = mrbm.MRBM(x0, h, **kwargs_6)
    s_6 = z_6.sample(N=N, record_trace=False, record_stats=False)
    z_6.dump(filename(6))


Generating z_6 samples...

In [149]:
fig = plt.figure(dpi=my_dpi, figsize=my_figsize)
xx1 = plt.hist(z_6.hist.midpoints, weights=z_6.hist.hist[0,:], normed=True, bins=52)
#yy1 = plt.plot(x_range, ys, 'r', lw=2) 
yy1 = plt.plot(x_range, ys2, 'g', lw=2) 
plt.title("Two Triangle Linkage with Fixed Center of Mass and Rotation with Boundaries")
plt.xlabel("Dihedral Angle")
plt.ylabel("Frequency")
plt.xlim(0.0, np.pi*2)
plt.savefig('T2_6.eps', dpi=my_dpi)



In [146]:
#z_6.hist.hist

In [146]: